package Code.Day10_20241011.com.dx.day10;

/**
 * @ClassName Test05
 * @Description 正则表达式
 * @Author 12994
 * @Date 2024/10/11 13:37
 * @Version 1.0
 **/
public class Test05 {
    public static void main(String[] args) {
        // 手机号
        String s1 = "13115511661";
        String reg1 = "^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$";
        System.out.println(s1.matches(reg1));
        // 身份证
        String s2 = "411403199811170102";
        String reg2 = "(^\\d{15}$)|(^\\d{18}$)|(^\\d{17}(\\d|X|x)$)";
        System.out.println(s2.matches(reg2));
        // 银行卡 19位
        String s3 = "6201010101123456789";
        String reg3 = "^(62|88)\\d{17,18}$";
        System.out.println(s3.matches(reg3));
        // 中文
        String s4 = "测试";
        String reg4 = "^[\\u4e00-\\u9fa5]*$";
        System.out.println(s4.matches(reg4));
        // 日期
        String s5 = "1998-1-14";
        String reg5 = "^\\d{4}-\\d{1,2}-\\d{1,2}";
        System.out.println(s5.matches(reg5));
        // 密码强度(至少8个字符，包含大写字母，小写字母、数字、特殊字符)
        String s6 = "Aa123456b*";
        String reg6 = "^\\S*(?=\\S{8,})(?=\\S*\\d)(?=\\S*[A-Z])(?=\\S*[a-z])(?=\\S*[!@#$%^&*? ])\\S*$";
        System.out.println(s6.matches(reg6));
        // IPV4地址
        String s7 = "127.0.0.1";
        String reg7 = "^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$";
        System.out.println(s7.matches(reg7));
    }
}
